/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Model;

import Data.ToaTau;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;

/**
 *
 * @author bienphongvnn
 */
public class ToaTauModel {
     public static ArrayList<ToaTau> ListToaTau(int loaitoa) {	
        ArrayList<ToaTau> ds = new ArrayList<ToaTau>();
        Connection con = ConnectionProvider.Connect();
	try {
            String sql = String.format("select distinct tt.MaToa from toatau tt, doantau dt where tt.MaTau = dt.MaTau and tt.LoaiToa = '%d'", loaitoa);
            Statement statement	= con.createStatement();	
            ResultSet rs = statement.executeQuery(sql);
            while(rs.next()){	
                ToaTau toa = new ToaTau();
                toa.MaToa = rs.getString("MaToa");
                ds.add(toa);
                } 
            con.close();
        }
        catch(Exception ex){
            System.out.println(ex.getMessage());	
        }
        finally
        {
           
        }
        return	ds;	
    }
}
